package com.lucweb.entity;

import javax.persistence.*;

/*
CREATE TABLE sys_question
(
  question_id         VARCHAR(255) NOT NULL
    PRIMARY KEY,
  question_name       VARCHAR(255) NULL,
  question_difficult  VARCHAR(255) NULL,
  question_solve      VARCHAR(255) NULL,
  question_time       VARCHAR(255) NULL,
  question_id_task_id VARCHAR(255) NULL,
  CONSTRAINT question_id_task_id
  FOREIGN KEY (question_id_task_id) REFERENCES sys_jctask (task_id)
);
CREATE INDEX question_id_task_id
  ON sys_question (question_id_task_id);



  查询外键数量语句
  SELECT task_id,task_name,task_time,COUNT(sys_question.question_id_task_id) AS count_id FROM sys_jctask INNER JOIN sys_question
    ON sys_jctask.task_id = sys_question.question_id_task_id GROUP BY sys_jctask.task_id ORDER BY sys_jctask.task_id, count_id;

 */


@Entity
@Table(name = "sys_question", schema = "firesystem", catalog = "")
public class Question {
    private String questionId;
    private String questionName;
    private String questionDifficult;
    private String questionSolve;
    private String questionTime;
    private Jctask sysJctaskByQuestionIdTaskId;

    @Id
    @Column(name = "question_id", nullable = false, length = 255)
    public String getQuestionId() {
        return questionId;
    }

    public void setQuestionId(String questionId) {
        this.questionId = questionId;
    }

    @Basic
    @Column(name = "question_name", nullable = true, length = 255)
    public String getQuestionName() {
        return questionName;
    }

    public void setQuestionName(String questionName) {
        this.questionName = questionName;
    }

    @Basic
    @Column(name = "question_difficult", nullable = true, length = 255)
    public String getQuestionDifficult() {
        return questionDifficult;
    }

    public void setQuestionDifficult(String questionDifficult) {
        this.questionDifficult = questionDifficult;
    }

    @Basic
    @Column(name = "question_solve", nullable = true, length = 255)
    public String getQuestionSolve() {
        return questionSolve;
    }

    public void setQuestionSolve(String questionSolve) {
        this.questionSolve = questionSolve;
    }

    @Basic
    @Column(name = "question_time", nullable = true, length = 255)
    public String getQuestionTime() {
        return questionTime;
    }

    public void setQuestionTime(String questionTime) {
        this.questionTime = questionTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Question question = (Question) o;

        if (questionId != null ? !questionId.equals(question.questionId) : question.questionId != null) return false;
        if (questionName != null ? !questionName.equals(question.questionName) : question.questionName != null)
            return false;
        if (questionDifficult != null ? !questionDifficult.equals(question.questionDifficult) : question.questionDifficult != null)
            return false;
        if (questionSolve != null ? !questionSolve.equals(question.questionSolve) : question.questionSolve != null)
            return false;
        if (questionTime != null ? !questionTime.equals(question.questionTime) : question.questionTime != null)
            return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = questionId != null ? questionId.hashCode() : 0;
        result = 31 * result + (questionName != null ? questionName.hashCode() : 0);
        result = 31 * result + (questionDifficult != null ? questionDifficult.hashCode() : 0);
        result = 31 * result + (questionSolve != null ? questionSolve.hashCode() : 0);
        result = 31 * result + (questionTime != null ? questionTime.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "question_id_task_id", referencedColumnName = "task_id")
    public Jctask getSysJctaskByQuestionIdTaskId() {
        return sysJctaskByQuestionIdTaskId;
    }

    public void setSysJctaskByQuestionIdTaskId(Jctask sysJctaskByQuestionIdTaskId) {
        this.sysJctaskByQuestionIdTaskId = sysJctaskByQuestionIdTaskId;
    }

    @Override
    public String toString() {
        return "Question{" +
                "questionId='" + questionId + '\'' +
                ", questionName='" + questionName + '\'' +
                ", questionDifficult='" + questionDifficult + '\'' +
                ", questionSolve='" + questionSolve + '\'' +
                ", questionTime='" + questionTime + '\'' +
                ", sysJctaskByQuestionIdTaskId=" + sysJctaskByQuestionIdTaskId +
                '}';
    }
}
